"""
基础赋值
"""
class Operator():
    def __init__(self,data_list=[],U_list=[],weight_list=[],heavy_weight_list=[],P_list=[],rate_list =[],matrix=[]):
        """
        function:初始化数据
        :param data_list:6个月的数据集
        :param U_list:诱导向量
        :param weight_list:加权向量
        :param heavy_weight_list:重加权向量
        :param P_list:概率向量
        :param rate_list:权重向量和概率向量的比率
        :param matrix:矩阵
        """
        if (len(data_list)):
            self.data_list = data_list
        else:
            self.data_list = [343.30,412.71,389.42,372.68,363.49,363.28]

        if (len(U_list)):
            self.U_list = U_list
        else:
            self.U_list = [5,15,10,20,30,25]

        if (len(weight_list)):
            self.weight_list = weight_list
        else:
            self.weight_list = [0.10,0.10,0.15,0.15,0.20,0.30]

        if (len(heavy_weight_list)):
            self.heavy_weight_list = heavy_weight_list
        else:
            self.heavy_weight_list = [0.10,0.10,0.20,0.20,0.20,0.30]

        if (len(P_list)):
            self.P_list = P_list
        else:
            self.P_list = [0.15,0.15,0.15,0.15,0.20,0.20]

        if (len(rate_list)):
            self.rate_list = rate_list
        else:
            self.rate_list = [0.6,0.4]

    def asc(self,a):
        """
        function:升序排列
        :param a: 一个数据集
        :return:
        """
        for i in range(len(a)):
            for j in range(i+1,len(a)):
                if a[j] < a[i]:
                    temp = a[i]
                    a[i] = a[j]
                    a[j] = temp
        return a

    def des(self,a):
        """
        function:降序排列
        :param a: 一个数据集
        :return:
        """
        for i in range(len(a)):
            for j in range(i+1,len(a)):
                if a[j] > a[i]:
                    temp = a[i]
                    a[i] = a[j]
                    a[j] = temp
        return a

    def U_asc(self,a):
        """
         function:对U进行升序排列，并获得其对应索引位置
        :param a: 一个数据集
        :return: 索引数组
        """
        # 对索引元组初始化
        u_index = [i for i in range(len(a))]
        for i in range(len(a)):
            for j in range(i+1,len(a)):
                if a[j] < a[i]:
                    temp = u_index[i]
                    u_index[i] = u_index[j]
                    u_index[j] = temp

        return u_index


